Repository navigation
Fixes open-metadata/openmetadata-collate#5526: revoke sessions on user delete and provider swap, stop logging tokens at DEBUG - #31423
Conversation
… logging tokens Three release-blocking findings from the 2.0.0 multi-pod platform test run, split out of #31410 so they can ship without the lower-severity items. SM-20 — soft delete did not revoke live sessions. Soft delete is the normal off-boarding action in the UI, so a removed user kept full API access until their token expired (7 days by default). UserRepository.postDelete — which already invalidates bot tokens and fires for both soft and hard delete — now revokes the user's sessions, and revocation already notifies the WebSocket and cross-pod listeners so peers drop their sockets too. Its secondary half: a login attempt by a deleted user answered 500 because the servlet auth paths have no JAX-RS exception mapper and their catch-all reported every failure as a server fault. Failures are now classified by the status they carry. SM-30 — at LOG_LEVEL=DEBUG, Jetty's HttpParser logged every request header verbatim, so support-requested DEBUG logs carried live bearer tokens and OM_SESSION cookies valid for up to 7 days. LOG_LEVEL sets the ROOT logger and nothing pinned the framework logger. Pinned in the shipped config, the h2 test config, and the three multi-pod dev configs. SSO-27 — swapping AUTHENTICATION_PROVIDER left sessions minted under the decommissioned provider valid until natural expiry, so moving IdPs to off-board users did not cut their access. Sessions already record their provider, so JwtFilter rejects one whose provider is no longer configured — checked per request against each pod's own config, so it holds cluster-wide without a session sweep. basic and openmetadata are treated as the same native-password provider: they are two historical names for one authenticator, and renaming one to the other must not log a whole deployment out. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
There was a problem hiding this comment.
Pull request overview
This PR addresses multi-pod security hardening around session lifecycle and sensitive logging by revoking user sessions on delete, invalidating sessions when the configured auth provider changes, and preventing Jetty from logging credentials when the root logger is set to DEBUG.
Changes:
- Add session revocation on user delete and provider-validation for session-bound JWTs.
- Introduce a shared servlet-auth failure response helper that preserves intended 4xx statuses and avoids leaking exception text by default.
- Pin Jetty logging level independently of
LOG_LEVELto prevent DEBUG header dumps ofAuthorization/OM_SESSION.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/security/session/SessionService.java | Adds bounded revokeSessionsForUser helper used to invalidate sessions on off-boarding. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/UserRepository.java | Hooks user deletion to revoke live sessions (soft + hard delete). |
| openmetadata-service/src/main/java/org/openmetadata/service/security/JwtFilter.java | Rejects session-bound tokens when the session was issued under a decommissioned auth provider (with basic/openmetadata equivalence). |
| openmetadata-service/src/main/java/org/openmetadata/service/security/SecurityUtil.java | Adds writeFailureResponse to map servlet-auth failures to appropriate HTTP status codes without exposing internal exception messages by default. |
| openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthServletHandler.java | Routes servlet-auth catch-all failure handling through SecurityUtil.writeFailureResponse. |
| openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthServletHandler.java | Routes servlet-auth catch-all failure handling through SecurityUtil.writeFailureResponse. |
| openmetadata-service/src/test/java/org/openmetadata/service/security/session/SessionServiceTest.java | Adds unit tests for revokeSessionsForUser behavior (revokes, no-op, stuck-row guard). |
| openmetadata-service/src/test/java/org/openmetadata/service/security/JwtFilterTest.java | Adds unit tests for provider-swap rejection and basic/openmetadata provider-name equivalence. |
| openmetadata-service/src/test/java/org/openmetadata/service/security/SecurityUtilTest.java | Adds unit tests for failure-response mapping (401 vs 404, preserved 4xx, generic 500 body). |
| conf/openmetadata.yaml | Pins org.eclipse.jetty logger level via JETTY_LOG_LEVEL to avoid DEBUG header dumps of credentials. |
| conf/openmetadata-h2-test.yaml | Pins org.eclipse.jetty logger level via JETTY_LOG_LEVEL for tests. |
| docker/development/distributed-test/local/server1.yaml | Pins org.eclipse.jetty logger level via JETTY_LOG_LEVEL in distributed-test local config. |
| docker/development/distributed-test/local/server2.yaml | Pins org.eclipse.jetty logger level via JETTY_LOG_LEVEL in distributed-test local config. |
| docker/development/distributed-test/local/server3.yaml | Pins org.eclipse.jetty logger level via JETTY_LOG_LEVEL in distributed-test local config. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| List<UserSession> sessions = | ||
| repository.findByUserIdAndStatus(userId, SessionStatus.ACTIVE, CLEANUP_BATCH_SIZE); | ||
| if (sessions.isEmpty()) { | ||
| break; | ||
| } |
| // A revoke that loses every compare-and-set leaves the session ACTIVE, so the next pass | ||
| // reads it back. Without this the loop burns all its passes on the same stuck rows and | ||
| // reports them as revoked once per pass. |
| level: ${LOG_LEVEL:-INFO} | ||
| loggers: | ||
| # LOG_LEVEL sets the ROOT logger, and at DEBUG Jetty's HttpParser prints every request header | ||
| # verbatim — including `Authorization: Bearer <jwt>` and `Cookie: OM_SESSION=<id>`. DEBUG is |
…leted revokeSessionsForUser queried ACTIVE only. A session holding a refresh lease sits in REFRESHING, invisible to that lookup, and completeRefresh / releaseRefreshLease put it back to ACTIVE afterwards — so a user deleted inside the 15s refresh window kept a live session for the full token lifetime, which is the hole SM-20 is supposed to close. Revoke both ACTIVE and REFRESHING. PENDING stays out: a login in flight has no user attached yet, so it can never be found by user id. Both stores support the lookup for any status — RedisSessionStore indexes every non-terminal status per user, JdbcSessionStore filters in SQL. Also corrected a comment that described the pre-review counting behaviour instead of the current one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks @copilot-pull-request-reviewer — two of the three were real and are fixed in 528d77f. The third I'm pushing back on. 1.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (1)
openmetadata-service/src/main/java/org/openmetadata/service/security/session/SessionService.java:631
- This inline comment is currently broken across lines ("// pass" on its own line), which hurts readability. Consider re-wrapping it into complete sentences.
// A revoke that loses every compare-and-set leaves the session where it was, so the next
// pass
// reads the same batch back. Stop instead of burning every remaining pass on rows that will
// not move; the cleanup sweep expires them at their timeout.
✅ Playwright Results — workflow succeededValidated commit ✅ 795 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 58m 51s ⏱️ Max setup 3m 5s · max shard execution 21m 48s · max shard-job elapsed before upload 25m 40s · reporting 6s 🌐 221.37 requests/attempt · 2.67 app boots/UI scenario · 15.90% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
Failed to cherry-pick changes to the 1.13 branch. |
Code Review ✅ ApprovedRevokes active sessions upon user deletion or authentication provider change, and stops logging sensitive tokens at DEBUG level. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Failed to cherry-pick changes to the 2.0 branch. |
…r delete and provider swap, stop logging tokens at DEBUG (#31423) * fix(security): revoke sessions on user delete and provider swap, stop logging tokens Three release-blocking findings from the 2.0.0 multi-pod platform test run, split out of #31410 so they can ship without the lower-severity items. SM-20 — soft delete did not revoke live sessions. Soft delete is the normal off-boarding action in the UI, so a removed user kept full API access until their token expired (7 days by default). UserRepository.postDelete — which already invalidates bot tokens and fires for both soft and hard delete — now revokes the user's sessions, and revocation already notifies the WebSocket and cross-pod listeners so peers drop their sockets too. Its secondary half: a login attempt by a deleted user answered 500 because the servlet auth paths have no JAX-RS exception mapper and their catch-all reported every failure as a server fault. Failures are now classified by the status they carry. SM-30 — at LOG_LEVEL=DEBUG, Jetty's HttpParser logged every request header verbatim, so support-requested DEBUG logs carried live bearer tokens and OM_SESSION cookies valid for up to 7 days. LOG_LEVEL sets the ROOT logger and nothing pinned the framework logger. Pinned in the shipped config, the h2 test config, and the three multi-pod dev configs. SSO-27 — swapping AUTHENTICATION_PROVIDER left sessions minted under the decommissioned provider valid until natural expiry, so moving IdPs to off-board users did not cut their access. Sessions already record their provider, so JwtFilter rejects one whose provider is no longer configured — checked per request against each pod's own config, so it holds cluster-wide without a session sweep. basic and openmetadata are treated as the same native-password provider: they are two historical names for one authenticator, and renaming one to the other must not log a whole deployment out. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(security): revoke a session that is mid-refresh when a user is deleted revokeSessionsForUser queried ACTIVE only. A session holding a refresh lease sits in REFRESHING, invisible to that lookup, and completeRefresh / releaseRefreshLease put it back to ACTIVE afterwards — so a user deleted inside the 15s refresh window kept a live session for the full token lifetime, which is the hole SM-20 is supposed to close. Revoke both ACTIVE and REFRESHING. PENDING stays out: a login in flight has no user attached yet, so it can never be found by user id. Both stores support the lookup for any status — RedisSessionStore indexes every non-terminal status per user, JdbcSessionStore filters in SQL. Also corrected a comment that described the pre-review counting behaviour instead of the current one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 9397048)
Describe your changes:
Fixes open-metadata/openmetadata-collate#5526
I worked on the three findings from the 2.0.0 multi-pod platform test run that gate the release,
split out of #31410 so they can ship on their own. #31410 keeps the remaining eleven — cookie↔JWT
binding, the WebSocket handshake tightening, Redis-outage 503s, cross-pod SSO config propagation, the
responseType/offline_access/ authority-normalization SSO fixes, and the observability nits —none of which are release blockers.
SM-20 — soft delete did not revoke live sessions. Soft delete is the normal off-boarding action
in the UI, so a removed user kept full API access until their token expired: 7 days by default,
across every pod. Verified in the original run on all 9 session×pod combinations.
SM-30 — bearer tokens and session cookies were written to the log at DEBUG.
LOG_LEVELsets theROOT logger and nothing pinned
org.eclipse.jetty, so itsHttpParserlogged every request headerverbatim: 14 raw JWTs, 18
OM_SESSIONvalues and 14Bearertokens per pod in a normal sessionworkload. DEBUG is exactly what support asks customers to enable, and those logs get attached to
tickets and shipped to aggregators carrying credentials valid for up to a week.
SSO-27 — swapping the auth provider did not invalidate old sessions. After moving IdPs, tokens
minted under the decommissioned provider stayed valid until natural expiry, so off-boarding a user by
moving IdPs did not cut their access. Same shape as SM-20, one layer up.
Type of change:
High-level design:
Revoke where every caller already routes.
UserRepository.postDeletefires for both soft andhard delete and already invalidates bot tokens, so revocation belongs there rather than in the
resource layer — a guard in the shared hook is smaller than a guard in each delete endpoint, and it
cannot be bypassed by a caller that takes a different route in.
SessionService.revokeSessionsForUseris built on the existing
findByUserIdAndStatus+revokeSessionprimitives and is bounded: eachpass reads at most
CLEANUP_BATCH_SIZE, and a pass that reads back an identical batch stops theloop — reusing the no-progress guard
expireSessionsInBatchesalready uses in that class ratherthan inventing a second one. Revocation already notifies the WebSocket and cross-pod listeners, so
peer pods drop the user's sockets without new plumbing.
Validate the provider, don't sweep sessions.
UserSessionalready records the provider thatauthenticated it, so
JwtFilterrejects a session whose provider is no longer configured. No storequery, no new endpoint, no cluster-wide sweep: each pod checks against its own current config, so it
holds everywhere. Enumerating and revoking every session on a config change would need a new
"find all active sessions" method on both store backends and would still race the reload.
basicandopenmetadataare deliberately treated as the same provider. They are two historicalnames for one native-password authenticator —
isNativePasswordProvidertreats them interchangeablyin six places and
BasicAuthServletHandlerserves both — so renaming one to the other, or a storedconfig normalizing one to the other across an upgrade, must not reject every live session. Without
that equivalence this change would log out a whole deployment on a no-op rename; there is a test
pinning it.
One classifier for the servlet auth paths. Those paths have no JAX-RS exception mapper, so their
catch (Exception) → 500 + e.getMessage()catch-all reported a rejected credential as a server faultand put the exception text on the wire.
SecurityUtil.writeFailureResponseclassifies instead.Three unrelated hierarchies carry an intended status and none share a supertype — JAX-RS
WebApplicationException,security.AuthenticationException, and the SDK'sWebServiceException(the parent of
CustomExceptionMessage, which is what the basic and LDAP authenticators actuallythrow for a rejected credential).
EntityNotFoundExceptionis checked first because it alsoextends the SDK class with
NOT_FOUND, and answering 404 on a login endpoint tells anunauthenticated caller which accounts exist. Anything unclassified stays a 500 with a generic
message; callers already log the exception.
Backward compatibility. SSO-27 is the one behaviour change with a blast radius worth naming: a
genuine provider swap now logs everyone out where it previously left old tokens working. That is the
finding. The
basic↔openmetadataequivalence above keeps a no-op rename from triggering it. SM-20and SM-30 are additive.
Tests:
Use cases covered
pod, instead of at token expiry. Hard delete is unchanged.
500.500too.LOG_LEVEL=DEBUGthe logs no longer containAuthorizationorOM_SESSIONvalues;JETTY_LOG_LEVELstill allows opting back in when someone genuinely needs wire-level Jetty debug.AUTHENTICATION_PROVIDERis swapped, tokens minted under the old provider are rejected onevery pod.
basic→openmetadata(or back) does not invalidate sessions.Unit tests
I added unit tests for the new/changed logic. 8 new tests, each verified to fail without its
fix by stashing the source file and re-running.
openmetadata-service/src/test/java/org/openmetadata/service/security/session/SessionServiceTest.java—
revokeSessionsForUserrevokes every active session; no-ops on a null user id; stops after twostore reads instead of twenty when a session cannot be revoked, and counts it as zero
.../security/JwtFilterTest.java— a session from a decommissioned provider is rejected; a sessionunder the other native-password provider name is accepted
.../security/SecurityUtilTest.java—writeFailureResponsekeeps the status of aCustomExceptionMessage(the deleted-user login path), maps a missing user to401rather than auser-enumerating
404, keeps the status of a rejected credential, and falls back to500withoutputting the exception text in the body
Coverage on changed classes,
mvn -Pstatic-code-analysis test jacoco:reportover the unit scopeabove —
SecurityUtil94.3%,SessionService77.5%,JwtFilter76.5%.UserRepository's addedlines are a delegating call whose logic is unit-tested in
SessionService; the class itself iscovered by ITs that need a live stack.
Backend integration tests
and a provider swap invalidating them — belong in the existing
SessionMultiNodeIT/SessionRedisMultiNodeITmulti-node suite. Happy to add them there if reviewers want them gatedon this PR rather than the multi-node run.
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
mvn spotless:check -pl openmetadata-service→ clean.basic/openmetadatacase fails withAuthenticationException: Not Authorized! Session was issued by a provider that is no longer configured.— i.e. without the equivalence it would log out the deployment.
lookUserInProviderthrowsCustomExceptionMessage(BAD_REQUEST, ...), which is not aWebApplicationException, which is whythe first version of this classifier still returned 500.
Not performed: a 3-pod cluster run against live IdPs. The findings came from that rig (per-scenario
evidence in the linked issue) and re-running it is the natural verification step. The two scenarios
to re-check are SM-20 (9 session×pod combinations after a soft delete) and SSO-27 (Google→basic swap,
then the old JWT across all pods).
UI screen recording / screenshots:
Not applicable — no UI changes in this PR.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Bug fix:
findings.
🤖 Generated with Claude Code